import { Store } from 'vuex'
import axios from '@/d2admin/plugin/axios'
import qs from 'qs'
import { MenuDelegateDefault } from '@/d2admin/delegate/menu'
import { delegate } from '@/d2admin/delegate'

/**
 * 自定义菜单实现类
 *  @author remexs
 */
class MenuDelegateImpl extends MenuDelegateDefault {
  /**
   * 获取Menu
   */
  loadMenu(store: Store<any>): Promise<void> {
    return new Promise(resolve => {
      const menuHeader = [
        { path: '/index', title: '首页', icon: 'home' },
        {
          title: '权限管理',
          icon: 'folder-o',
          children: [
            { path: '/system/access/curd', title: '模型访问权限' },
            { path: '/system/request/curd', title: '参数校验' }
          ]
        }
      ]
      const menuAside = [
        { path: '/index', title: '首页', icon: 'home' },
        {
          title: 'apijson测试',
          icon: 'folder-o',
          children: [
            { path: '/apijson/test/curd', title: '模型访问权限' }
          ]
        },
        {
          title: '模型访问权限',
          icon: 'folder-o',
          children: [
            { path: '/system/access/curd', title: '模型访问权限' },
            { path: '/system/request/curd', title: '参数校验' }
          ]
        }
      ]
      // 设置顶栏菜单
      // store.commit('d2admin/menu/headerSet', menuHeader, { root: true })
      // 设置侧边栏菜单
      store.commit('d2admin/menu/asideSet', menuAside, { root: true })
      // 初始化菜单搜索功能
      store.commit('d2admin/search/init', menuHeader, { root: true })
      resolve()
    })
  }
}

export default new MenuDelegateImpl()
